home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.demo_apps;
-
- import sub_arctic.lib.*;
- import sub_arctic.input.*;
- import sub_arctic.output.*;
- import sub_arctic.constraints.std_function;
-
- import java.util.Vector;
-
- /**
- * This is a demo applet for how a mailer might work/look in sub_arctic.
- */
- public class mail_test extends debug_interactor_applet {
- /* from box */
- listbox from;
- /* subject box */
- listbox subject;
- /* date box */
- listbox date;
- /* menubar */
- menubar bar;
- /* the vertical scrollbar */
- v_scrollbar sbar;
- /* the list of things to do */
- listbox todo_list;
- /*
- * These two base_parent_interactors are the two big sections of
- * the interface. top_section is the top part of the interface with
- * the listboxes, bot_section is the botom part with the messges.
- */
- base_parent_interactor top_section, bot_section, list_section;
- /**
- * This function returns the interactor that is the playing field
- * where all the messages get displayed.
- */
- public interactor playing_field() { return bot_section;}
- /*
- * The messages
- */
- Vector msg;
-
- /*
- * Data Structure Setup
- */
- public void pre_build_ui() {
- /* for now, just fetch a vector of message objects */
- msg=message.retreive_messages();
- }
- /**
- * Initialize top section of the interface
- */
- public void build_top_section(base_parent_interactor top) {
- /* we will override the size in a second with constraints */
- top_section=new base_parent_interactor(0,0,10,10);
- /* constraint to be the size of the top level interface and
- * to be as tall as the separator allows
- */
- top_section.set_w_constraint(std_function.offset(PARENT.W(),0));
- top_section.set_h_constraint(std_function.fill(ZERO, NEXT_SIBLING.Y(),0));
- /* put it into the top level */
- top.add_child(top_section);
- /* now build the sub_interactors */
- from=new header_listbox(false,this);
- subject=new header_listbox(false,this);
- date=new header_listbox(false,this);
- sbar=new listbox_v_scrollbar(from);
- separator sep1=new separator(9,10/* constrained later*/,true),
- sep2=new separator(9, 10/* constrained later */,true);
-
- /* layout constraints on listboxes */
- from.set_x_constraint(std_function.offset(PREV_SIBLING.X2(),0));
- from.set_y_constraint(std_function.offset(ZERO,0));
- from.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
- NEXT_SIBLING.X(),0));
- from.set_h_constraint(std_function.offset(PARENT.H(),0));
-
- subject.set_x_constraint(std_function.offset(PREV_SIBLING.X2(),0));
- subject.set_y_constraint(std_function.offset(ZERO,0));
- subject.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
- NEXT_SIBLING.X(),0));
- subject.set_h_constraint(std_function.offset(PARENT.H(),0));
-
- date.set_x_constraint(std_function.offset(PREV_SIBLING.X2(),0));
- date.set_y_constraint(std_function.offset(ZERO,0));
- date.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
- PARENT.X2(),0));
- date.set_h_constraint(std_function.offset(PARENT.H(),0));
-
- /* we don't want any space around our objects other than the bevel */
- from.set_left_space(0);
- subject.set_left_space(0);
- date.set_left_space(0);
- from.set_right_space(0);
- subject.set_right_space(0);
- date.set_right_space(0);
-
- /* constrain the separators to size appropriately in Y */
- sep1.set_y_constraint(std_function.offset(PREV_SIBLING.Y(),0));
- sep1.set_h_constraint(std_function.offset(PREV_SIBLING.H(),0));
- sep2.set_y_constraint(std_function.offset(PREV_SIBLING.Y(),0));
- sep2.set_h_constraint(std_function.offset(PREV_SIBLING.H(),0));
-
- /* initialize the position of each sep */
- sep1.set_x(250);
- sep2.set_x(575);
- /* take out the vertical scrollbars */
- from.set_vertical_status(listbox_display.SCROLLBAR_NEVER);
- subject.set_vertical_status(listbox_display.SCROLLBAR_NEVER);
- date.set_vertical_status(listbox_display.SCROLLBAR_NEVER);
- /* make these objects be in a group */
- from.add_to_group(date);
- subject.add_to_group(date);
- /* constrain our own scrollbar */
- sbar.set_y_constraint(std_function.offset(PARENT.Y(),3));
- sbar.set_h_constraint(std_function.offset(NEXT_SIBLING.H(),-6));
- sbar.set_x_constraint(std_function.offset(ZERO,5));
- /* make our scrollbar control the first one */
- from.set_external_v_scrollbar(sbar);
- /* add everybody */
- top_section.add_child(sbar); /* must be first */
- top_section.add_child(from);
- /* add the first separator */
- top_section.add_child(sep1);
- top_section.add_child(subject);
- /* add the second separator */
- top_section.add_child(sep2);
- top_section.add_child(date);
- }
- /**
- * Build the bottom section of the interface.
- */
- public void build_bottom_section(base_parent_interactor top) {
- base_parent_interactor bot_parent;
- label l;
- /* build the interactor that will hold the two important
- interactors */
- bot_parent=new base_parent_interactor(0,0,10,10);
- bot_parent.set_y_constraint(std_function.eq(PREV_SIBLING.Y2()));
- bot_parent.set_w_constraint(std_function.eq(PARENT.W()));
- bot_parent.set_h_constraint(std_function.fill(PREV_SIBLING.Y2(),
- PARENT.Y2(),10));
- top.add_child(bot_parent);
-
- /* build the list section */
- list_section=new base_parent_interactor(0,0,10,10); /* override these */
- list_section.set_x_constraint(std_function.offset(PARENT.X(),1));
- list_section.set_h_constraint(std_function.offset(PARENT.H(),0));
- list_section.set_w_constraint(std_function.eq(MAX_CHILD.W()));
- bot_parent.add_child(list_section);
- /* put the list and label in */
- l=new label("To Do List");
- l.set_x_constraint(std_function.centered(PARENT.W(),0));
- l.set_y(5);
- list_section.add_child(l);
- todo_list=new todo_listbox(this);
- todo_list.set_x(0);
- todo_list.set_y_constraint(std_function.eq(PREV_SIBLING.Y2()));
- todo_list.set_h_constraint(std_function.fill(PREV_SIBLING.Y2(),
- PARENT.Y2(),0));
- list_section.add_child(todo_list);
-
- /* we are going to override the y position and the height & width
- with constraints */
- bot_section=new base_parent_interactor(0,0,10,10);
- bot_section.set_x_constraint(std_function.eq(PREV_SIBLING.X2()));
- bot_section.set_w_constraint(std_function.fill(PREV_SIBLING.X2(),
- PARENT.X2(),0));
- bot_section.set_h_constraint(std_function.eq(PARENT.H()));
-
- bot_parent.add_child(bot_section);
- }
- /**
- * Initialize UI after build.
- */
- public void post_build_ui(base_parent_interactor top) {
- int i;
- message m;
- Vector from_line=new Vector(), subject_line=new Vector(), date_line=new Vector();
-
- /* from line */
- for (i=0; i<msg.size(); ++i) {
- /* get the message out */
- m=(message)msg.elementAt(i);
- /* copy */
- m=m.copy();
- /* set the display property */
- m.set_display_field(0);
- from_line.addElement(new object_list_element(m));
- }
- /* subject line */
- for (i=0; i<msg.size(); ++i) {
- /* get the message out */
- m=(message)msg.elementAt(i);
- /* copy */
- m=m.copy();
- /* set the display property */
- m.set_display_field(2);
- subject_line.addElement(new object_list_element(m));
- }
- /* date line */
- for (i=0; i<msg.size(); ++i) {
- /* get the message out */
- m=(message)msg.elementAt(i);
- /* copy */
- m=m.copy();
- /* set the display property */
- m.set_display_field(1);
- date_line.addElement(new object_list_element(m));
- }
- /* put in the boxes */
- from.set_contents(from_line);
- subject.set_contents(subject_line);
- date.set_contents(date_line);
- }
- /*
- * Construct the user interface
- */
- public void build_ui(base_parent_interactor top) {
- separator y_sep=new separator(10 /* constrained later */,9,false);
- build_top_section(top);
- /* put in the vertical separator */
- y_sep.set_x(0);
- y_sep.set_y(160);
- y_sep.set_w_constraint(std_function.offset(PARENT.W(),0));
- top.add_child(y_sep);
- /* put in the bottom area */
- build_bottom_section(top);
- }
- /**
- * Return the todo_listbox that is in use.
- */
- public interactor todo_listbox() {
- return todo_list;
- }
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-